<?php

/* 
 *------------------------------------------------------------------------------
 * Project Name  : e-Synergy Library System
 *         Code  : ESN-LBS
 *
 * Created By    : Junlapong
 *         Date  : 2010/01/21
 * 
 * $Id$
 *------------------------------------------------------------------------------
 *    copyright: e-Synergy Co., Ltd.
 *==============================================================================
 */

if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * esn_common_script
 *
 * @access  public
 * @return  html
 */
if (!function_exists('esn_common_script'))
{	
    function esn_common_script()
    {
    	$html = "";
    	
    	// JavaScript
    	$html .= "<script type=\"text/javascript\">\n";
    	$html .= "    var diff_time = new Date().getTime() - " . (time() * 1000) . "\n";
    	$html .= "</script>\n";
    	
    	$html .= "<script type=\"text/javascript\" src=\"" . site_url('scripts/jquery-1.4.min.js') . "\"></script>\n";
    	//$html .= "<script type=\"text/javascript\" src=\"" . site_url('scripts/jquery-1.4.js') . "\"></script>\n";
    	$html .= "<script type=\"text/javascript\" src=\"" . site_url('scripts/common.js') . "\"></script>\n";
    	$html .= "<script type=\"text/javascript\" src=\"" . site_url('scripts/date.format.js') . "\"></script>\n";
    	
    	// CSS
    	$html .= "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . site_url('styles/common.css') . "\" />\n";
		$html .= "<!--[if IE]>\n";
		$html .= "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . site_url('styles/common-ie.css') . "\" />\n";
		$html .= "<![endif]-->\n";
		
		return $html;    	
    }
}

/**
 * esn_tooltip
 *
 * @access  public
 * @text    string
 * @length  number
 * @return  html
 */
if (!function_exists('esn_tooltip'))
{	
    function esn_tooltip($text, $length = 20)
    {
        $_text = htmlspecialchars_decode($text, ENT_QUOTES);
        $tip   = "";
        $html  = "";
        
        if (mb_strlen($_text) > $length)
        {
            $html = htmlspecialchars(mb_substr($_text, 0, $length, 'UTF-8'));
            $html .= " ...";
            $tip = $text;
        }
        else
        {
            $html = htmlspecialchars($_text);
        }
        
        $html = "<span class='tooltiptext' title='" . $tip . "'>" . $html . "</span>";
        
        return $html;
    }
}

/**
 * escape_html
 *
 * @str_html       string
 * @return         escape htmlspecialchars
 */
if (!function_exists('escape_html'))
{
    function escape_html($str_html)
    {
        return htmlspecialchars($str_html, ENT_QUOTES);
    }
}

// ------------------------------------------------------------------------

/**
 * debug data
 * 
 * @param $str
 * @param $exit
 */
function debug($str, $exit = FALSE)
{
    echo "<pre>";
    print_r($str);
    echo "</pre>";

    if ($exit)
    {
        exit(0);
    }
}

/* End of file esn_helper.php */
/* Location: application/helpers/esn_helper.php */